package ru.tulupov.producerconsumerpattern;

import java.util.ArrayList;

/**
 * ArrayList with fixed size
 * 
 * @author <a href="mailto:zhekka3@gmail.com">Eugene Tulupov</a>
 */
public class FixedSizeArrayList<T> extends ArrayList<T> {

	private static final long serialVersionUID = -8790679820777141773L;
	private final int capacity;

	public FixedSizeArrayList(int capacity) {
		super(capacity);
		this.capacity = capacity;
	}

	@Override
	public boolean add(T element) {
		if (size() >= capacity) {
			return false;
		}
		return super.add(element);
	}

}